#ifndef __AXIOS_H
#define __AXIOS_H

#include "cJSON.h"
#include "log.h"
#include "vec.h"
#include <arpa/inet.h>
#include <error.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <unistd.h>
#include <fcntl.h>

typedef enum {
    MEVEN_HTTP_GET,
    MEVEN_HTTP_POST,
    MEVEN_HTTP_PUT,
    MEVEN_HTTP_DELETE,
    MEVEN_HTTP_HEAD,
    MEVEN_HTTP_OPTIONS,
    MEVEN_HTTP_PATCH,
    MEVEN_HTTP_TRACE,
    MEVEN_HTTP_CONNECT,
} HTTP_METHOD;

typedef enum {
    RESPONSE_OK = 200,
    RESPONSE_NOT_FOUND = 404,
    RESPONSE_BAD_REQUEST = 401,
} RESPONSE_CODE;

typedef struct client {
    char *key;
    char *value;
} entry;

typedef struct {
    RESPONSE_CODE code;
    char *message;
    cJSON *body;
} response_t;

typedef Vec(entry) headers_t;
extern const char *methods[9];
extern int sockfd;
extern fd_set read_fds;
extern struct timeval tv;

response_t *request(HTTP_METHOD method, char *path, headers_t *headers, cJSON *root);

void client_connect(char *host, int port);

void response_free(response_t *response);

#endif